package cn.crm.bean;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Right entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "RIGHTS", schema = "CRM")
public class Right implements java.io.Serializable {

	// Fields

	private String rid;
	private Right right;
	private String parentid;
	private String rname;
	private Short zindex;
	private String rurl;
	private Boolean ztype;
	private Set<RightMaping> rightMapings = new HashSet<RightMaping>(0);
	private Set<Right> rights = new HashSet<Right>(0);

	// Constructors

	/** default constructor */
	public Right() {
	}

	/** minimal constructor */
	public Right(String rid, Right right, String rname) {
		this.rid = rid;
		this.right = right;
		this.rname = rname;
	}

	/** full constructor */
	public Right(String rid, Right right, String parentid, String rname,
			Short zindex, String rurl, Set<RightMaping> rightMapings,
			Set<Right> rights) {
		this.rid = rid;
		this.right = right;
		this.parentid = parentid;
		this.rname = rname;
		this.zindex = zindex;
		this.rurl = rurl;
		this.rightMapings = rightMapings;
		this.rights = rights;
	}

	// Property accessors
	@Id
	@Column(name = "RID", unique = true, nullable = false, length = 8)
	public String getRid() {
		return this.rid;
	}

	public void setRid(String rid) {
		this.rid = rid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parentid", unique = true, nullable = false, insertable = false, updatable = false)
	public Right getRight() {
		return this.right;
	}

	public void setRight(Right right) {
		this.right = right;
	}

	@Column(name = "PARENTID", length = 8)
	public String getParentid() {
		return this.parentid;
	}

	public void setParentid(String parentid) {
		this.parentid = parentid;
	}

	@Column(name = "RNAME", nullable = false, length = 20)
	public String getRname() {
		return this.rname;
	}

	public void setRname(String rname) {
		this.rname = rname;
	}

	@Column(name = "ZINDEX", precision = 4, scale = 0)
	public Short getZindex() {
		return this.zindex;
	}

	public void setZindex(Short zindex) {
		this.zindex = zindex;
	}

	@Column(name = "RURL", length = 35)
	public String getRurl() {
		return this.rurl;
	}

	public void setRurl(String rurl) {
		this.rurl = rurl;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "right")
	public Set<RightMaping> getRightMapings() {
		return this.rightMapings;
	}

	public void setRightMapings(Set<RightMaping> rightMapings) {
		this.rightMapings = rightMapings;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "right")
	public Set<Right> getRights() {
		return this.rights;
	}

	public void setRights(Set<Right> rights) {
		this.rights = rights;
	}

	@Column(name = "ztype", precision = 1, scale = 0)
	public Boolean getZtype() {
		return ztype;
	}

	public void setZtype(Boolean ztype) {
		this.ztype = ztype;
	}
	
	

}